#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N = 2e5 + 10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n, a[N];
void solve()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];

    int ans = 0;
    for (int i = n - 1; i >= 1;)
    {
        
        if (a[i] != a[n])
        {
            ans++;
            i=n-(n-i)*2;//越界就越界下次又进不来
        }
        else i--;
    }
    cout << ans << '\n';

}

int main()
{
    close();
    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}
//后值赋给前值
//al+i=al+k+i
//不要模拟不越界的情况,越界了就退出就好